<?php $form = $this->beginWidget('CActiveForm', array('id' => 'video-form', 'enableAjaxValidation' => true)); ?>
<table cellspacing="1" cellpadding="4" width="100%">
    <tr align="center" valign="top">
        <td width="*" align="center" valign="top"><!-- ######### begin ######### -->
            <div class="Block">
                <div class="BlockBar"><?php echo CHtml::activeLabel($model, 'files_add_title'); ?></div>
                <!-- tab bar -->
                <div id="tabbar-div">
                    <ul>
                        <li class="tab-back" id="general"><a href="<?php echo $this->createUrl('update', array('id' => $model->video_id));?>">基本信息</a></li>
                        <li class="tab-front" id="details">视频路径</li>
                    </ul>
                </div>
                <!-- tab end -->
                <?php echo $form->errorSummary($model); ?>
                <table width="100%" cellpadding="4" cellspacing="1" class="tab">
                    <tbody class="tabbar general">
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'type'); ?>:</td>
                            <td><?php echo $form->dropDownList($model, 'type', $model->inputMode, array('separator' => '', 'class' => 'radio', 'onclick' => 'show(this)')); ?></td>
                        </tr>
                        <tr class="row hide" id="input_type_1">
                            <td width="100" class="align-right"><?php echo $form->labelEx($model, 'urllist'); ?>:</td>
                            <td><?php echo $form->textArea($model, 'urllist', array('cols' => '50')); ?><?php echo $form->error($model, 'urllist'); ?></td>
                        </tr>
                    </tbody>
                    <tbody id="input_type_0" class="tabbar general">
                        <tr class="row">
                            <td width="100" class="align-right"><?php echo Yii::t('default', '批量生成视频路径'); ?></td>
                            <td><div class="left space-level"><?php echo $form->textField($model, 'prefix', array('size' => 40)); ?> <?php echo $form->textField($model, 'start', array('size' => 3, 'value' => $this->start)); ?>至<?php echo $form->textField($model, 'end', array('size' => 3, 'value' => $this->end)); ?>视频格式<?php echo $form->textField($model, 'extension', array('size' => 5)); ?></div>
                                <?php echo CHtml::submitButton(Yii::t('default', '生成点播地址'), array('class' => 'btns', 'id' => "makePlay", 'name' => 'make')); ?></td>
                        </tr>
                        <?php if ($model->files): ?>
                            <tr class="row">
                                <td></td>
                                <td>
                                    <div id="urlItem">
                                        <div><span class="url"><?php echo $form->labelEx($model, 'file_path'); ?></span><span class="title"><?php echo $form->labelEx($model, 'file_name'); ?></span><span class="type"><?php echo $form->labelEx($model, 'type'); ?></span><span></span></div>
                                        <?php foreach ($model->files as $file): ?>
                                            <div>
                                                <span><?php echo $form->textField($model, 'url[]', array('class' => 'url', 'value' => $file['file_path'])); ?></span>
                                                <span><?php echo $form->textField($model, 'name[]', array('value' => $file['file_name'])); ?></span>
                                                <span class="type"><?php echo $form->dropDownList($model, 'type[]', $model->filePlayMode); ?></span>
                                                <span><?php echo CHtml::button(Yii::t('default', '删除'), array('class' => 'btns remove', 'url' => $this->createUrl('delfile', array('fid' => $file['fid'], 'vid' => $model->video_id))));?></span>
                                            </div>
                                             <?php echo $form->hiddenField($model, 'fid', array('value' => $file['fid']));?>
                                                <?php endforeach; ?>
                                    </div>

                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                    <tr class="rows">
                        <td class="rows"></td>
                        <td class="rows"><?php echo CHtml::submitButton(Yii::t('app', '保 存'), array('class' => 'btn')); ?></td>
                    </tr>
                </table>
                <?php echo $form->hiddenField($model, 'video_id'); ?>
            </div></td>
        <td width="5"></td>
        <td width="250" align="center" valign="top"><div class="Block-Menu-Define">
                <div class="BlockBar"><?php echo Yii::t('default', '选择视频所在服务器'); ?></div>
                <div class="BlockLinks">
                    <ul>
                        <li><?php echo $form->error($model, 'server'); ?></li>
                        <?php echo $model->getServerList($model->server); ?>
                    </ul>
                </div>

            </div></td>
    </tr>
</table>
<?php $this->endWidget(); ?>
<script>
    $(".remove").click(function (){
        
        $.get($(this).attr('url'));
        $(this).parent().parent().remove();
        
    });
    function show(obj){
        if($(obj).val() == 0){
            $('#input_type_1').hide();
            $('#input_type_0').show();
        }else{
            $('#input_type_1').show();
            $('#input_type_0').hide();
        }
    }
</script>
